package com.ly.designpatten.single;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @Classname LazySingleEnum
 * @Description TODO
 * @Date 2020/10/5 14:59
 * @Author 冷心影翼
 */
public enum LazySingleEnum {
	LAZY_SINGLE_ENUM;

	LazySingleEnum(){
		System.out.println("initLazySingleEnum");
	}

}


class TestLazySingleEnum {

	public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
		for(int i=0;i<10;i++) {
			new Thread(()->{LazySingleEnum l = LazySingleEnum.LAZY_SINGLE_ENUM;}).start();
		}

		Constructor<LazySingleEnum> constructor = LazySingleEnum.class.getDeclaredConstructor(null);

		constructor.setAccessible(true);
		LazySingleEnum lazySingleInnerClass = constructor.newInstance();
		LazySingleEnum lazySingleInnerClass1 = constructor.newInstance();
	}
}